package com.zb.spring5.ioc.entity;

public class Singer {

    private static final String DEFAULT_NAME = "zhangbo";
    private  String name;
    private  int age = Integer.MIN_VALUE;

    public void setName(String name) {
        this.name = name;
    }
    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Singer{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public void init(){
        System.out.println("Initializing bean");
        if(name == null)
        {
            System.out.println("Using default name");
            name = DEFAULT_NAME;
        }
        if (age == Integer.MIN_VALUE){
            throw  new IllegalArgumentException(
                    "你必须设置"+Singer.class+"的age属性值"
            );
        }
    }
}
